#pragma once
#include "subframe.h"

//class QButtonGroup;
//class QDate;
//class QGridLayout;
//class QVBoxLayout;
//class QHBoxLayout;
#include <QString>
#include <QStringList>
class QTreeWidget;
class QTreeWidgetItem;
class QTextEdit;
class QMenu;
class QDate;

class FormDiary :
	public SubFrame
{
	Q_OBJECT
public:
	FormDiary(QWidget * parent = 0,	Qt::WFlags f = 0);
public:
	~FormDiary(void);
private:
	QTreeWidget*	m_treeWidget;
	QTextEdit*		m_textEdit;
	QStringList		m_strList;
	QString			m_strCurFileName;
	static const	QString m_strRoot;
	QMenu*			m_menuPop;
	bool			m_modified;

private slots:
	void treeClicked(QTreeWidgetItem* item, int column);
	void showTreeMenu(const QPoint & pos);
	void createDiary(void);
	void saveDiary(void);
	void deleteDiary(void);
	void textChanged(void);
private:
	void createDiary(const QDate& date);
	bool setCurFileName(QString& name);
	void loadFile(void);
	void initTree(const QDate& date);
public:
	virtual void save(void);
	virtual void fileNew(void);
	virtual void open(void);
	virtual void fileDelete(void);
private:
	bool isDiaryExist(const QDate& date);
};
